using System;
using System.Linq;
using Repository.Abstract;
using DomainModel.Entities;
using Service.Abstract;

namespace Service.Concrete
{
    public class UserService : IUserService
    {
        private readonly IUserRepository _userRepository;

        public UserService(IUserRepository userRepository)
        {
            _userRepository = userRepository;
        }

        public IQueryable<User> GetAllUser()
        {
            var users = from u in _userRepository.AllUsers
                        select u;

            return users;
        }

        public User GetUserById(Guid userId)
        {
            var user = (from u in _userRepository.AllUsers
                        where u.UserId == userId
                        select u).SingleOrDefault();

            return user;
        }
    }
}